<%--
  Created by IntelliJ IDEA.
  User: qiliping
  Date: 15/11/22
  Time: 下午12:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="paging" uri="paging-taglib" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>


<html>
<head>
    <title>基金列表</title>
    <script>
        $(function(){
            $(".isrec").click(function(){
                var obj = $(this);
                var confr="";
                var isr = $(this).attr("isr");
                if(isr==1){
                    confr="确认要取消首页推荐吗?";
                }else{
                    confr="确认要首页推荐吗?";
                }
                if(confirm(confr)){
                    var aid = $(this).attr("aid");
                    $.ajax({
                        url:"/product/product_recommend_to_home",
                        type:"post",
                        data:{id:aid},
                        success:function(res){
                            if(res == 1) {
                                if (isr == 1) {
                                    obj.text("推荐到首页");
                                    obj.attr("isr", "0");
                                } else {
                                    obj.text("取消首页推荐");
                                    obj.attr("isr", "1");
                                }
                            }
                        }
                    })
                }

            });
        })
    </script>
</head>
<body>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title">
            基金管理
            <small>基金列表</small>
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="${ctx}/main">
                    首页
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="${ctx}/product">
                    基金管理
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="#">
                    基金列表
                </a>
            </li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
    </div>
</div>
<!-- END PAGE HEADER-->
<!------内容区----->
<div class="main">
    <form action="${ctx}/product" method="get">
        <div class="row">
            <div class="col-md-12">
                <div class="search">
                    <div class="form-group">
                        <label class="control-label">基金名称：</label>
                        <input type="text" name="q" value="${q}" class="form-control form-control-inline"/>
                    </div>

                    <div class="form-group">
                        <label class="control-label">成立时间：</label>

                        <div class="date-control small">
                            <div class="input-daterange input-group">
                                <input type="text" class="form-control fromdatetime col-md-3" size="16" value="${stime}"
                                       name="stime">
                                <span class="input-group-addon"> - </span>
                                <input type="text" class="form-control todatetime col-md-3" size="16" value="${etime}"
                                       name="etime">
                            </div>
                        </div>
                    <span class="actions">
                        <input class="btn blue" type="submit" value="搜索"/>
                    </span>
                        <span class="actions">
                        <div class="text-right">
                            <a href="${ctx}/product/add" class="btn blue">发布基金</a>
                        </div>
                    </span>
                    </div>
                </div>

            </div>
        </div>

        <%--<div class="row">
            <div class="col-md-12">
                <div class="text-right">

                    <div class="btn-group status-filter">
                        <label class="btn btn-default active">
                            <a class="toggle checked" href="${ctx}/product">所有</a>
                        </label>
                        <label class="btn btn-default">
                            <a class="toggle" href="${ctx}/product?status=3">预约中</a>
                        </label>
                        <label class="btn btn-default">
                            <a class="toggle" href="${ctx}/product?status=4">募集中</a>
                        </label>

                    </div>
                </div>
            </div>
        </div>--%>

        <div class="row">
            <div class="col-md-12">
                <table class="table table-striped table-hover zqy-table">
                    <thead>
                    <tr>
                        <th>基金编号</th>
                        <th>基金名称</th>
                        <th>基金管理人</th>
                        <th>基金经理</th>
                        <%--<th>托管银行</th>--%>
                        <%--<th>券商</th>--%>
                        <th>总规模</th>
                       <%-- <th>初始规模</th>--%>
                        <th>最低投资</th>
                        <th>成立时间</th>
                        <th>状态</th>
                        <th>是否开放购买</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="item" items="${lists}">
                        <tr>
                            <td>${item.productCode}</td>
                            <td><a href="javascript:void(0);">${item.productName}</a></td>
                            <td>${item.fundCompanyName}</td>
                            <td>${item.fundManagerName}</td>
                            <%--<td>${item.fundCustodianName}</td>--%>
                            <%--<td>${item.fundTradingBroker}</td>--%>
                            <td>
                                <fmt:formatNumber value="${item.productTotalScale}" pattern=",000"></fmt:formatNumber>万元
                                <br />
                                已募集:<fmt:formatNumber value="${item.hasInvestAmount}" pattern=",000"></fmt:formatNumber>万元
                            </td>
                            <%--<td>
                                <fmt:formatNumber value="${item.productInitialScale}" pattern=",000"></fmt:formatNumber>万元

                            </td>--%>
                            <td>
                                    ${item.minInvsetAmount}万元

                            </td>

                            <td>
                                <fmt:formatDate value="${item.registerDate}" pattern="yyyy-MM-dd"/>
                            </td>
                            <td>
                                <c:choose>
                                    <c:when test="${item.productStatus == 0}">
                                        草稿中
                                    </c:when>
                                    <c:when test="${item.productStatus == 3}">
                                        预约中
                                    </c:when>
                                    <c:when test="${item.productStatus == 4}">
                                        募集中
                                    </c:when>
                                    <c:when test="${item.productStatus == 8}">
                                        运行中
                                    </c:when>
                                    <c:when test="${item.productStatus == 9}">
                                        已结束
                                    </c:when>
                                </c:choose>
                            </td>
                            <td>
                                <c:choose>
                                    <c:when test="${item.isOpenSale==0}">
                                        未开放购买
                                    </c:when>
                                    <c:otherwise>
                                        已开放购买(<fmt:formatDate value="${item.openSaleDate}" pattern="yyyy-MM-dd"></fmt:formatDate> )
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td>
                                    <c:choose>
                                        <c:when test="${item.productStatus==0}">
                                        <a href="${ctx}/product/edit?id=${item.productId}">编辑</a>
                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when test="${item.recommendType==0}">
                                                    <a href="javascript:void(0);" class="isrec" isr="${item.recommendType}" aid="${item.productId}">推荐</a>
                                                </c:when>
                                                <c:otherwise>
                                                    <a href="javascript:void(0);" class="isrec" isr="${item.recommendType}" aid="${item.productId}">取消推荐</a>
                                                </c:otherwise>
                                            </c:choose>

                                        </c:otherwise>
                                    </c:choose>

                                <c:if test="${item.productStatus!=9}">
                                    <a href="${ctx}/product/netvalue/${item.productId}">净值走势</a>
                                    <a href="${ctx}/product/change_status?id=${item.productId}">状态变更</a>
                                    <a href="${ctx}/product/redeem_date?id=${item.productId}">赎回时间段</a>
                                </c:if>
                                <c:if test="${item.productStatus == 8}">

                                    <a href="${ctx}/product/year_settlement?id=${item.productId}">基金年度结算</a>
                                </c:if>

                                <c:if test="${item.productStatus==8&&item.isOpenSale==0}">
                                    <a href="${ctx}/product/open_sale?id=${item.productId}">开放购买</a>
                                </c:if>
                                <c:if test="${item.productStatus==8&&item.isOpenSale==1}">
                                    <a href="${ctx}/product/open_sale?id=${item.productId}">关闭购买</a>
                                </c:if>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <div class="text-center">
                    <ul class="pagination">
                        <paging:paging pageIndex="${pageIndex}" totalPage="${totalPage}" href="${ctx}/product"
                                       htmlTag="li"></paging:paging>

                    </ul>
                </div>

            </div>
        </div>

    </form>
</div>
<!------[end]内容区----->

</body>
</html>